function [result] = deal_sensor_msg(pose_file1,pose_file2)
%这个函数传入两个table，分别格式化保存了两个cartographer建图的odom相对于map的位姿。
%输出两个位姿的差。
%   pose1,pose2分别为两个位姿文件。result为结果数组。
pose1 = readtable(pose_file1);
pose2 = readtable(pose_file2);
flag_p2 = 1;
size_p1 = size(pose1);
size_y = size_p1(2);
size_p1 = size_p1(1);

try
    for i = 1:size_p1
        if pose1(i,"Var2").Variables == pose2(flag_p2, "Var2").Variables
            x_t = pose1(i,"Var4").Variables - pose2(flag_p2, "Var4").Variables;
            y_t = pose1(i,"Var6").Variables - pose2(flag_p2, "Var6").Variables;
            z_t = pose1(i,"Var8").Variables - pose2(flag_p2, "Var8").Variables;
            x_o = pose1(i,"Var10").Variables - pose2(flag_p2, "Var10").Variables;
            y_o = pose1(i,"Var12").Variables - pose2(flag_p2, "Var12").Variables;
            z_o = pose1(i,"Var14").Variables - pose2(flag_p2, "Var14").Variables;
            w_o = pose1(i,"Var16").Variables - pose2(flag_p2, "Var16").Variables;
            result(i,:) = [pose1(i,"Var2").Variables ,x_t, y_t, z_t, x_o, y_o, z_o, w_o];
            flag_p2 = flag_p2 + 1;
        elseif pose1(i,"Var2").Variables < pose2(flag_p2, "Va2").Variables
            continue
        else
            flag_p2 = flag_p2 + 1;
        %flag_p2 = flag_p2 + 1
        end
    end
catch
    disp("Reach the end of pose2 table. Quit.");
end

s = size(result);
s = s(1)
space_result = zeros(1, s);
for i = 1:s
    space_result(i) = sqrt(power(result(i,2), 2) + power(result(i,3), 2) + power(result(i,4), 2))
end

end

